package com.parktech.sun.domain.service.aboutus.impl;

import com.parktech.sun.domain.model.aboutus.AboutUs;
import com.parktech.sun.domain.repository.BaseRepository;
import com.parktech.sun.domain.repository.aboutus.AboutUsRepository;
import com.parktech.sun.domain.service.aboutus.AboutUsService;
import com.parktech.sun.domain.service.impl.BaseServiceImpl;
import org.hibernate.Criteria;
import org.hibernate.criterion.Property;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * User: Think
 * Date: 11-1-13
 * Time: 下午10:57
 */
@Service
public class AboutUsServiceImpl extends BaseServiceImpl<AboutUs> implements AboutUsService {

    private AboutUsRepository aboutUsRepository;

    @Autowired
    public AboutUsServiceImpl(AboutUsRepository aboutUsRepository) {
        super(aboutUsRepository);
        this.aboutUsRepository = aboutUsRepository;
    }

    public AboutUs getByCategory(String category) {
        Criteria criteria = aboutUsRepository.createCriteria();
        criteria.add(Property.forName("category").eq(category));
        return (AboutUs) criteria.uniqueResult();
    }
}
